]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
iconGrid.js: Animate icon spring using translation
authorDaniel van Vugt <daniel.van.vugt@canonical.com>
Fri, 10 Jan 2020 09:37:26 +0000 (17:37 +0800)
committerDaniel van Vugt <daniel.van.vugt@canonical.com>
Mon, 13 Jan 2020 08:23:37 +0000 (16:23 +0800)
Animating the icon spring using the `translation-x/y` properties instead
of the `x/y` properties avoids relayouts. There are still other non-icon
actors moving, but it's a big improvement.

Before: 595 relayouts per spring
After: 94 relayouts per spring

Reducing relayouts reduces reallocation, which reduces CPU-intensive
JavaScript execution.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/926

js/ui/iconGrid.js

index 11ea0a7f92fb7bbb8e5de37ae1de6490e1b100f3..0495bd089318705e65909b10f7a73a38a8caa3db 100644 (file)
@@ -557,14 +557,14 @@ var IconGrid = GObject.registerClass({
 
                 actorClone.opacity = 0;
                 actorClone.set_scale(scaleX, scaleY);
-
-                actorClone.set_position(adjustedSourcePositionX, adjustedSourcePositionY);
+                actorClone.set_translation(
+                    adjustedSourcePositionX, adjustedSourcePositionY, 0);
 
                 let delay = (1 - (actor._distance - minDist) / normalization) * ANIMATION_MAX_DELAY_FOR_ITEM;
                 let [finalX, finalY]  = actor._transformedPosition;
                 movementParams = {
-                    x: finalX,
-                    y: finalY,
+                    translation_x: finalX,
+                    translation_y: finalY,
                     scale_x: 1,
                     scale_y: 1,
                     duration: ANIMATION_TIME_IN,
@@ -585,12 +585,12 @@ var IconGrid = GObject.registerClass({
                 let isLastItem = actor._distance == maxDist;
 
                 let [startX, startY]  = actor._transformedPosition;
-                actorClone.set_position(startX, startY);
+                actorClone.set_translation(startX, startY, 0);
 
                 let delay = (actor._distance - minDist) / normalization * ANIMATION_MAX_DELAY_OUT_FOR_ITEM;
                 movementParams = {
-                    x: adjustedSourcePositionX,
-                    y: adjustedSourcePositionY,
+                    translation_x: adjustedSourcePositionX,
+                    translation_y: adjustedSourcePositionY,
                     scale_x: scaleX,
                     scale_y: scaleY,
                     duration: ANIMATION_TIME_OUT,